Creating An Amazon RDS Instance for MariaDB and Connecting From Alpha Cloud

Description

This document is a walk-through of creating a MariaDB Amazon RDS (Relational Database Service) instance and database that you can use with the Alpha Anywhere development environment and an application deployed on Alpha Cloud.

Overview

This guide walks you through the process of creating an Amazon RDS Instance using MariaDB and connecting to the MariaDB instance with an application deployed using Alpha Cloud. This guide covers the following:

Creating a MariaDB Amazon RDS Instance and Database

In this section we will create an Amazon RDS MariaDB instance and database.

Before we can create the instance, however, we first need to create a parameter group that sets some MariaDB parameters to make working with the database easier from Alpha Anywhere. We will be setting the parameters below as follows:

NameValueDescription
log_bin_trust_function_creators1Allows you to create functions and stored procedures.
lower_case_table_names1Makes table names case insensitive and simplifies hand coding queries.
max_allowed_packet500000000The value we have chosen (500 million) allows you to save large binary and text columns in the database.

We will create both an instance and a database. You can create additional database on the same instance if you wish.

  1. Sign in your Amazon Account or create a new Amazon Account at http://aws.amazon.com

  2. From the Amazon Web Services page navigate to RDS (Relational Database Service) by clicking on the "Services" icon on the top left of the toolbar, selecting "Database" and then "RDS" in the menus. Please note that this article is based on the Amazon AWS Console user interface that is current as of this writing. The instructions are meant to give you a general sense of the specific settings when creating a database for use with Alpha Anywhere rather than as a replacement for Amazon AWS documentation. The AWS Console web page layout changes relatively frequently and may not match exactly. Consult Amazon Relational Database Service documentation in that event.

  3. Important – Be sure to select the Amazon Region you will be deploying your application in when you create your RDS Instance. You will get better performance on your deployed applications.

  4. Create a Parameter Group for your new MariaDBInstance to make working within Alpha Anywhere easier:

    • a. On the RDS Dashboard, click on the Parameter Groups menu item on the left of the page.

    • b. Click the button labeled "Create parameter Group".

    • c. Select "mariadb 10.0 from the Parameter Group Family dropdown list. Note that you can choose any version of MariaDB on the list, but it should match the database version you intend to create.

    • d. Enter a group name (Let's use "MariaDBAA"). The name should be unique for parameter groups within your account.

    • e. Enter a reasonable description for the new group like "MariaDB parameter group for use with Alpha Anywhere".

    • f. Click the button to the right entitled "Create".

  5. Update the values of three of the parameters in your new parameter group:

    • From the RDS Dashboard click Parameter Groups, select your parameter group by clicking on the checkbox and click the button at the top entitled "Edit Parameters".

    • Scroll down to log_bin_trust_function_creators and set the value to 1. A value of 1 will allow you to create functions and stored procedures.

    • Scroll down to lower_case_table_names and set that value to 1. A value of 1 enables support for case-insensitive table names and simplifies hand coding queries.

    • Scroll down to max_allowed_packet and set that to 500000000 (500 million). This value can vary. The suggested value of 500000000 allows you to save large binary and text columns in the database.

    • Scroll to the top of the page and click the button entitled "Save Changes".

  6. Create your Amazon RDS instance and database:

    • Return to the Amazon RDS Dashboard

    • If you have no instances click on Get Started Now

    • If you have existing instances, click on the button labeled "Launch a DB Instance". Note that the button at the top launches an Amazon Aurora DB Instance.

    • From the options presented, click on the MariaDB icon on the left.

    • Click the button entitled "Select" on the right.

    • Click the radio button entitled Dev/Test and MariaDB. Note that you can also choose a Production implementation if you wish. The Dev/Test option creates a smaller instance and can save money while you are learning.

    • Click the button entitled "Next Step"

    • From the first page of options entitled "Specify DB Details", choose the following:

      DB Engine Version

      10.0.24 is a good choice.

      DBInstance Class

      db.t2.micro is sufficient for our purposes but you can choose a larger (and more expensive class if you wish).

      Multi-AZ Deployment

      For our example, you can choose No.

      For test databases, you don't need Multi-AZ deployment.

      For production you will want to choose this option as it causes multiple server instances to be run in multiple physical data centers (called availability zones) and assures better availability and load balancing.

      Allocated Storage

      You can work with as little as 20GB. Feel free to use more. Amazon recommends at least 100GB for production performance.

      DB Instance identifier

      Name your instance. "MariaDB" works fine if you don't already have one with that name.

      Master Username

      Choose a user name for the database owner.

      Master Password

      Enter the password you want to use for your database owner. Reenter it in Confirm Password.

    • Leave all other options at their default values.

      Click the button on the bottom right entitled "Next Step"

  7. On the page entitled "Configure Advanced Settings"

    • a. Leave VPC, Subnet Group, Publicly Available, Availability Zone and VPC Security Group(s) at their default values. Note that a new security group will be created by default. This group will grant access to the IP from which you are logged in.

    • b. Set the Database name to create a new database. We can use "Test1"

    • c. Select the DB Parameter Group MariaDBAA (the one we just created).

    • d. Set Minor Version Upgrade to Yes to take advantage of automatic upgrades.

      You can also set a Backup Retention Period and Maintenance Window for the upgrades.
    • e. Leave all other options at their defaults.

    • f. Click the button at the bottom right entitled "Launch DB Instance".

    • g. Click the button at the bottom of the next page entitled "View Your New Instances" this will return you to the Instances page of the RDS Dashboard and will show your new database in the "creating" status.

It make take five to ten minutes to create the database. You can continue with some of the other tasks while you wait.

Granting Access to Your RDS Database Instance

Step 1: Editing Security to Allow Database Access from AlphaCloud

  1. From the RDS Dashboard, click on the menu item entitled "Instances" on the left.

  2. Check the box to the left of the database we just created.

  3. Click on the black arrow between the checkbox and the database Engine column to display more information on the database.

  4. Click on the icon showing a document with a magnifying glass to see the details tab.

    The Endpoint will say "Not available yet" until your database is created.
  5. Click on the link to the right of the "Security Groups" item to go to the Security Groups page for the security group that was automatically created for us along with our database.

  6. If you select the security group, and click on the tab at the bottom of the page entitled "Inbound", you will see a rule that includes the IP address from which you created the RDS database.

  7. Click the "Edit" button in the Inbound tab page to display the edit dialog for the inbound rules.

  8. Click the button entitled "Add Rule".

  9. Select MySQL/Aurora as the type.

  10. Select "Custom" as the Source.

    If you had selected 'Anywhere' above, the CIDR address of 0.0.0.0/0 would be set and your database could be accessed from anywhere on the internet. Instead, you want to add specific addresses from which access is allowed. This will prevent anyone not at one of these addresses from accessing your database.
  11. Add a rule for each egress IP address (from which Alpha Cloud will access the database) and one for your local address.

    The format of the address is the IP address you want to allow followed by "/32". This means that you want the incoming IP address to match all 32 bits of the IP address you are providing.
  12. Click Save to save the new inbound rules.

Step 2: Retrieve the Endpoint for your new Database Instance

  1. Return to RDS Instances page:

    • a. Click on the cube on the upper left corner of the page.

    • b. Click on the RDS (Relational Database Service) menu item.

    • c. Click on the Instances option on the left of the RDS Dashboard page.

  2. Once your database status reports as "available" select your new database.

  3. Click on the black arrow to the left of the Engine column with on the row your database is displayed on.

  4. Select the EndPoint value and copy it to the clipboard.

    The endpoint will look something like this:

    mariadb.ctdi74iuxpca.us-east-1.rds.amazonaws.com:3306

  5. Save this value for later.

Connecting from a Modeling Tool

Depending on your choice of tool to model the schema of your database, you will have a different dialog, but they will all use the following values:

Server or Host

This is the front part of the endpoint without the ":3306"

Port

This is the value 3306

User

The master user name you created

Password

The master user password you created

Some tools will work with the server and let you select the database, others will prompt for the database as part of the connection.

Database

Use the name you created for your database. In the steps above. We used "Test1"

Connecting from Alpha Anywhere

  1. Create a named connection string in the Alpha Anywhere Web Project

    • a. Open the Web Control Panel

    • b. Select Tools and then AlphaDAO Connection Strings from the menu.

    • c. If you have an existing named connection string in use for your project, you can edit it and have it point to your new RDS database.

    • d. Otherwise, click "New" to create a new connection string.

    • e. Choose the MySQL client

    • f. On the Create SQL Connection String dialog enter the following values:

      Hostname

      Your saved endpoint without the ":3306"

      Port

      3306

      User

      The master user name you provided when you created your database

      Password

      The password you provided when you created your database

      Database

      Enter the name of the database you created with your instance. We used "Test1".

      You can click on the button entitled "Refresh" to retrieve a list of databases.
    • g. Click on Test Connection to confirm that you have connected to your RDS instance successfully.

  2. Give your new named connection a unique name within your web project.

  3. Use this named connection for all of your development.

  4. When you publish to Alpha Cloud, the connection will work from your deployed applications as well.